package grsu.epam.airline.service;

import grsu.epam.airline.DAO.ISpecialityDAO;
import grsu.epam.airline.DAOImpl.DAOFactory;
import grsu.epam.airline.constant.Constant;
import grsu.epam.airline.model.Speciality;

import java.sql.SQLException;
import java.util.ArrayList;

public class SpecialityService {
	public ArrayList<Speciality> getAllSpeciality() {
		ISpecialityDAO specialityDao = (ISpecialityDAO) DAOFactory
				.getInstance().getDAO(Constant.SpecialityDAO);
		ArrayList<Speciality> specialities = null;
		try {
			specialities = (ArrayList<Speciality>) specialityDao
					.getAllSpeciality();
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			DAOFactory.getInstance().closeConnection(
					specialityDao.getConnection());
		}
		return specialities;
	}

}
